package com.alks.function.controller.biocontrol.deptwork;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.entity.data.entity.CpLastInfo;
import com.alks.entity.data.entity.CpLastStyle;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.service.biocontrol.deptwork.ICpLastService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@ApiRestController("/bioDeptWrok")
@Api(value = "生控作业", tags = "生控部-生控作业-楦头资料建档")
@RequiredArgsConstructor
@RoleCheck(prgIds = "140116")
public class CpLastController {
    private final ICpLastService service;

    @PostMapping("/getLastInfoQuery")
    @ApiOperation(value = "楦头资料查询-可条件查询", tags = "生控部-生控作业-楦头资料建档")
    public ResponseInfo getLastInfoQuery(@RequestParam(required = false) @ApiParam("楦头号") String lastNo,
                                         @RequestParam(required = false) @ApiParam("型体") String style) {
        return service.getLastInfoQuery(lastNo, style);
    }

    @PutMapping("/lastInfoAdd")
    @ApiOperation(value = "楦头资料新增-新增", tags = "生控部-生控作业-楦头资料建档")
    public ResponseInfo lastInfoAdd(@RequestBody CpLastInfo request) {
        return service.lastInfoAdd(request);
    }

    @PutMapping("/lastInfoUpdate")
    @ApiOperation(value = "楦头资料更新-更新", tags = "生控部-生控作业-楦头资料建档")
    public ResponseInfo lastInfoUpdate(@RequestBody CpLastInfo request,
                                       @RequestParam@ApiParam("旧楦头") String lastNoOld) {
        return service.lastInfoUpdate(request,lastNoOld);
    }

    @PostMapping("/lastInfoDelete")
    @ApiOperation(value = "楦头资料删除-删除", tags = "生控部-生控作业-楦头资料建档")
    public ResponseInfo lastInfoDelete(@RequestParam@ApiParam("楦头") String lastNo) {
        return service.lastInfoDelete(lastNo);
    }

    @PostMapping("/getLastStyleQuery")
    @ApiOperation(value = "楦头型体查询-条件查询", tags = "生控部-生控作业-楦头资料建档")
    public ResponseInfo getLastStyleQuery(@RequestParam@ApiParam("楦头号") String lastNo) {
        return service.getLastStyleQuery(lastNo);
    }

    @PutMapping("/lastStyleAdd")
    @ApiOperation(value = "楦头型体新增-新增", tags = "生控部-生控作业-楦头资料建档")
    public ResponseInfo lastStyleAdd(@RequestBody@ApiParam("型体") List<String> style,
                                     @RequestParam@ApiParam("楦头") String lastNo) {
        return service.lastStyleAdd(style,lastNo);
    }

    @PutMapping("/lastStyleUpdate")
    @ApiOperation(value = "楦头型体更新-更新", tags = "生控部-生控作业-楦头资料建档")
    public ResponseInfo lastStyleUpdate(@RequestBody CpLastStyle request,
                                        @RequestParam@ApiParam("旧型体") String styleOld) {
        return service.lastStyleUpdate(request,styleOld);
    }

    @PostMapping("/lastStyleDelete")
    @ApiOperation(value = "楦头型体删除-删除", tags = "生控部-生控作业-楦头资料建档")
    public ResponseInfo lastStyleDelete(@RequestParam@ApiParam("楦头") String lastNo,
                                        @RequestParam@ApiParam("型体") String style) {
        return service.lastStyleDelete(lastNo,style);
    }

    @PostMapping("/getLastSizeQuery")
    @ApiOperation(value = "楦头号码查询-条件查询", tags = "生控部-生控作业-楦头资料建档")
    public ResponseInfo getLastSizeQuery(@RequestParam@ApiParam("楦头号") String lastNo) {
        return service.getLastSizeQuery(lastNo);
    }

    @PostMapping("/lastSizeDelete")
    @ApiOperation(value = "楦头号码删除-删除", tags = "生控部-生控作业-楦头资料建档")
    public ResponseInfo lastSizeDelete(@RequestParam@ApiParam("楦头号") String lastNo,
                                       @RequestParam@ApiParam("序号") String seqNo) {
        return service.lastSizeDelete(lastNo,seqNo);
    }

}
